Skip to content

Bring over embeddings support from the PHP AI Client - #892

Merged
dkotter merged 11 commits into
WordPress:developfrom
dkotter:feature/embeddings-client-support
Aug 11, 2026
Merged

Bring over embeddings support from the PHP AI Client#892
dkotter merged 11 commits into
WordPress:developfrom
dkotter:feature/embeddings-client-support

Conversation

@dkotter

@dkotter dkotter commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What?

Brings the embedding related changes over from the PHP AI Client and loads those conditionally when needed, allowing us to start supporting that work.

Why?

Embedding supported was added to v1.4.0 of the PHP AI Client. We were hoping to get this in to WordPress 7.1 but that has been pushed now to 7.2. Instead of having to wait until WordPress 7.2 is released to take advantage of this new functionality, this PR pulls that code into the AI plugin, behind a conditional gate, so we can start taking advantage of that earlier.

How?

  • Pulls the embedding related code from the PHP AI Client into an includes/Vendor/AiClient directory
  • Adds an SDK_Overlay class that loads this code, if needed, on top of the code WordPress itself loads. This allows us to continue to use the PHP AI Client that ships with WordPress while also loading in this new embedding code. This approach can be used in the future for any other PHP AI Client changes we want to start using sooner
  • Adds in helper functions that can be used to determine if embedding generation is supported via the PHP AI Client and can be used to generate embeddings

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Brainstorming and planning the initial approach and then executing on that approach. Final review and testing by me

Testing Instructions

Easiest way to test is via the custom WP-CLI command this PR has. Note you'll also need to install an AI Provider plugin that supports embeddings.

  1. Pull this PR down
  2. Ensure you have an AI Provider plugin installed, activated and configured that supports embeddings: OpenAI PR, Google PR, Ollama PR
  3. Open up a terminal window
  4. Run wp ai embeddings generate 'This is some text'
  5. You should get a message like Dry run: would have generated embeddings for text: This is some text
  6. Run wp ai embeddings generate 'This is some text' --dry-run=false
  7. You should see a success message and information about the provider and model used as well as the embedding value (trimmed)
  8. Try other versions of the command and ensure they work as expected:
  • wp ai embeddings generate --post-id=42 --dry-run=false
  • wp ai embeddings generate --post-id=42 --chunk --dry-run=false
  • wp ai embeddings generate 'This is some text' --provider=ollama --dry-run=false

Changelog Entry

Added - Brought the embedding code over from the PHP AI Client and load that conditionally so those using the AI plugin can start to take advantage of embedding generation.

Open WordPress Playground Preview

@dkotter dkotter added this to the 1.3.0 milestone Jul 23, 2026
@dkotter dkotter self-assigned this Jul 23, 2026
@dkotter
dkotter requested a review from a team July 23, 2026 19:36
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dkotter dkotter changed the title Feature/embeddings client support Bring over embeddings support from the PHP AI Client Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.33270% with 771 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.46%. Comparing base (a1df313) to head (d61443d).

Files with missing lines Patch % Lines
.../AiClient/src/Providers/Models/DTO/ModelConfig.php 31.35% 243 Missing ⚠️
...es/Vendor/AiClient/src/Providers/ModelResolver.php 14.81% 115 Missing ⚠️
...ent/src/Providers/Models/DTO/ModelRequirements.php 43.71% 112 Missing ⚠️
...endor/AiClient/src/Results/DTO/EmbeddingResult.php 0.00% 103 Missing ⚠️
.../Vendor/AiClient/src/Builders/EmbeddingBuilder.php 28.39% 58 Missing ⚠️
...udes/Vendor/AiClient/src/Results/DTO/Embedding.php 0.00% 40 Missing ⚠️
includes/SDK_Overlay.php 51.28% 38 Missing ⚠️
...lient/src/Builders/Traits/ModelResolutionTrait.php 0.00% 22 Missing ⚠️
...iClient/src/Events/AfterGenerateEmbeddingEvent.php 0.00% 19 Missing ⚠️
...Client/src/Events/BeforeGenerateEmbeddingEvent.php 0.00% 15 Missing ⚠️
... and 1 more
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #892      +/-   ##
=============================================
- Coverage      80.31%   75.46%   -4.85%     
- Complexity      2591     2924     +333     
=============================================
  Files            111      121      +10     
  Lines          10536    11597    +1061     
=============================================
+ Hits            8462     8752     +290     
- Misses          2074     2845     +771     
Flag Coverage Δ
unit 75.46% <27.33%> (-4.85%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jeffpaul
jeffpaul previously approved these changes Aug 10, 2026
@jeffpaul jeffpaul moved this from Triage to Needs review in WordPress AI Roadmap Aug 10, 2026
@jeffpaul jeffpaul mentioned this pull request Aug 10, 2026
44 tasks
…ode. Modify it a bit to have detection be lazy, meaning it only detects support when needed instead of all the time
@dkotter
dkotter merged commit 1608cbf into WordPress:develop Aug 11, 2026
21 of 24 checks passed
@github-project-automation github-project-automation Bot moved this from Needs review to Done in WordPress AI Roadmap Aug 11, 2026
@dkotter
dkotter deleted the feature/embeddings-client-support branch August 11, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants